package com.webchat.client.mall.service;


import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.exception.BusinessException;
import com.webchat.domain.vo.request.mall.ShopSubmitRequestVO;
import com.webchat.domain.vo.response.mall.MallShopBaseVO;
import com.webchat.rmi.pgc.mall.MallShopClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MallShopService {

    @Autowired
    private MallShopClient mallShopClient;

    /**
     * 申请开店
     * @param shopSubmitRequestVO
     * @return
     */
    public Long submit(ShopSubmitRequestVO shopSubmitRequestVO) {

        APIResponseBean<Long> responseBean = mallShopClient.submit(shopSubmitRequestVO);
        if (APIResponseBeanUtil.isOk(responseBean)) {
            return responseBean.getData();
        }
        throw new BusinessException("提交失败:" + responseBean.getMsg());
    }

    /**
     * 查询账号下的店铺信息
     *
     * @param userId
     * @return
     */
    public MallShopBaseVO shopInfo(String userId) {
        APIResponseBean<MallShopBaseVO> responseBean = mallShopClient.manageShopInfo(userId);
        if (APIResponseBeanUtil.isOk(responseBean)) {
            return responseBean.getData();
        }
        return null;
    }
}
